package demo;

public class Fib {
	public static void main(String[] args) {
		System.out.println(fib(7));
		
	}
	public static int fib(int n) {
//		if(n < 1)return -1;
//		if(n == 1 || n==2)return 1;
//		return fib(n-1)+fib(n-2);
	
		if (n < 1)
			return -1;
		if (n == 1 || n == 2)
			return 1;
		int up = 1;
		int upp = 1;
		int res = 0;
		for (int i = 3; i <= n; i++) {
			res = up + up;
			up = up;
			up = res;

		}
		return res;
	}

}
